<?php

$r = new Redis();
$host = '127.0.0.1';
$port = '6379';
$r->connect($host, $port);
$key = 'this_is_a_test';
echo $r->setex($key, 10, 1);
echo $r->get($key);

exit;
// function a(closure $func)
// {
//     call_user_func($func, $d);
// }

// a(function($query) use($data){

// })

$keys = [
    '13485815268',
    '18735609971',
    '13095087777',
    '17763037893',
    '13997973870'
];

$vals = [
    1,2,3,4,5
];

$result = array_combine($keys, $vals);

var_dump($result);

exit;
$task = [];
//init parse_error's value
//!isset($task['parse_error']) and $task['parse_error'] = 0;
//retry once only

$runTimes = 3;

for ($i=0; $i < $runTimes; $i++) {
    if (isset($task['parse_error']) && $task['parse_error'] >= $i+1) {
        //if queue has only one task,unset it will cause query_queue length to 0,and will finished in following code
    }else{
        $task['on_request'] = true;
        $task['parse_error']++;
    }
}

var_dump($task);

exit;
$status = 1;

$conditions = [];
$statusSet = ['0','1','2','3'];
if(is_array($status)){
    $status = array_intersect($status, $statusSet);
    count($status) > 0 and $conditions['status IN'] = $status;
}elseif($status{0} === '!'){
    $conditions['status !='] = substr($status, 1);
}elseif(is_numeric($status) && in_array($status, $statusSet)){
    $conditions['status'] = $status;
}

var_dump($conditions);
exit;
$mobilephone = '86-13202110878';
echo str_replace('86-', '', $mobilephone);
exit;

$a = [0,2];

$b1 = '0';
$b1 = '';
$b2 = 2;
$b4 = '2';

var_dump(is_numeric($b1) && in_array($b1, $a));

exit;
const SCRIPT_RUN_TIME_RANGE_START = '09:00:00';
const SCRIPT_RUN_TIME_RANGE_END = '21:00:00';

date_default_timezone_set('PRC');

function intCompare(){
    $time = time();
    return strtotime(SCRIPT_RUN_TIME_RANGE_START) <= $time && $time <= strtotime(SCRIPT_RUN_TIME_RANGE_END);
}

function strCompare(){
    $time = date('H:i:s').PHP_EOL;
    return SCRIPT_RUN_TIME_RANGE_START  <  $time && $time < SCRIPT_RUN_TIME_RANGE_END;
}

$timer = [];
$total = 10000;
$timer['runTotal'] = $total;
$timer['start'] = microtime(true);
for ($i=0; $i < $total; $i++) {
    // var_dump(intCompare());
    var_dump(strCompare());
}
$timer['end'] = microtime(true);
$timer['diff'] = $timer['end'] - $timer['start'];

echo implode(',', $timer);
// 1479892287.2506,1479892287.3056,0.054957151412964
// 1479892325.2356,1479892325.2731,0.037482023239136
